#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
char a[N];
int s[N];
int main() {
  int tc;
  cin >> tc;
  while (tc--) {
    memset(s, 0, sizeof s);
    int cnt = 0;
    int n, k;
    cin >> n >> k;
    cin >> a;
    for (int i = 0; i < n; ++i) {
      if (a[i] == '1') {
        int start = max(i - k, 0);
        int end = min(i + k + 1, n);
        s[start]--;
        s[end]++;
      }
    }
    for (int i = 1; i <= n; ++i) {
      s[i] += s[i - 1];
    }
    for (int i = 0; i < n; ++i) {
      if (s[i] == 0 && a[i] == '0') {
        cnt++;
        i += k;
      }
    }
    cout << cnt << endl;
  }
}
